// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

#ifndef MGCBEZIERPATCH_H
#define MGCBEZIERPATCH_H

// This class exists solely to support MgcBezierMesh.

#include "MgcObject.h"
class MgcColor;
class MgcTriMesh;
class MgcVector2;
class MgcVector3;


class MgcBezierPatch : public MgcObject
{
    MgcDeclareRTTI;
    MgcDeclareStream;

public:
    // abstract base class for specific type and degree patches
    virtual ~MgcBezierPatch ();

    enum PatchType
    {
        PT_TRIANGLE,
        PT_RECTANGLE,
        PT_CYLINDER
    };

    virtual PatchType GetType () const = 0;

    // member access
    unsigned int GetDegree () const;
    unsigned int GetIndexQuantity () const;
    const unsigned int* Indices () const;

    // tessellation
    virtual void Tessellate (unsigned int uiLevel,
        const MgcVector3* akCtrlPoint, const MgcColor* akCtrlColor,
        const MgcVector2* akCtrlTexture, MgcTriMesh* pkMesh,
        unsigned int& ruiVertexStart, unsigned int& ruiTriangleStart) = 0;

    static unsigned int GetVerticesPerTrianglePatch (unsigned int uiLevel);
    static unsigned int GetVerticesPerRectanglePatch (unsigned int uiLevel);
    static unsigned int GetVerticesPerCylinderPatch (unsigned int uiLevel,
        unsigned int uiCLevel);
    static unsigned int GetTrianglesPerTrianglePatch (unsigned int uiLevel);
    static unsigned int GetTrianglesPerRectanglePatch (unsigned int uiLevel);
    static unsigned int GetTrianglesPerCylinderPatch (unsigned int uiLevel,
        unsigned int uiCLevel);

protected:
    // Construction and destruction.  MgcBezierPatch accepts responsibility
    // for deleting the input array.
    MgcBezierPatch (unsigned int uiDegree, unsigned int uiIndexQuantity,
        unsigned int* auiIndex);

    MgcBezierPatch ();

    unsigned int m_uiDegree;
    unsigned int m_uiIndexQuantity;
    unsigned int* m_auiIndex;
};

MgcSmartPointer(MgcBezierPatch);
MgcRegisterStream(MgcBezierPatch);
#include "MgcBezierPatch.inl"

#endif
